package com.ylsf.blog.controller;


import com.ylsf.blog.service.LoginService;
import com.ylsf.blog.service.impl.LoginServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 登录控制类
 */
@WebServlet("/logins")
public class LoginServlet extends HttpServlet {
    private LoginService loginService=new LoginServiceImpl();
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("utf-8");
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        System.out.println(username+password);
        if (loginService.judgeLogin(username,password)) {
            response.getWriter().print("登陆成功");
            System.out.println("登陆成功");
        }else {
            response.getWriter().print("登陆失败");
        }
    }

}
